package com.pattern.composite;




/**
 * @Description: 叶子节点
 * @Author: whp
 * @Date: 2021-02-07 14:57
 */
public class Leaf extends Component{

    String name;
    public Leaf(){}
    public Leaf(String name){
        this.name=name;
    }

    @Override
    public void add(Component comopent) {
        System.out.println("叶子节点不能添加节点");
    }

    @Override
    public void remove(Component comopent) {
        System.out.println("叶子节点不能删除节点");
    }

    @Override
    public void display(int level) {

    }


    @Override
    public Component getChild(int i) {
        return null;
    }

    @Override
    public void operation() {
        System.out.println("树叶"+name+"被访问");
    }
}
